<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <div id="box">hello</div>
    <!-- 我是注释内容 -->
    <script>
        //元素节点

        var div = document.getElementById('box')
        console.log(div.nodeType); //1
        //nodeType：判断节点的类型
        // 属性节点
        console.log(div.attributes[0].nodeType); //2

        //文本节点
        console.log(div.firstChild.nodeType); //3

        //注释节点
        console.log(div.nextSibling.nodeType); //8

        //文档节点
        console.log(document.nodeType); //9

        // nodeName获取节点的名称
        //元素节点
        //nodeValue获取节点的值
    </script>
</body>

</html>